package ex.mlist;

import java.util.List;



import Database.Ringtone;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class MusicAdapter extends BaseAdapter {
	
	private Context mContext;
	List<Ringtone> lis;
	int count;
	private LayoutInflater mInflater;
	public MusicAdapter(Context c,List<Ringtone> lis) {
		
		mContext = c;
		mInflater = LayoutInflater.from(mContext);
		this.lis=lis;
	}

	public int getCount() {
		return lis.size();
	}

	public Object getItem(int position) {
		return lis.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		System.gc();
		ViewHolder holder;
		if (convertView == null) {
			
			holder = new ViewHolder();
			convertView = mInflater.inflate(R.layout.list,null);
		
			holder.Name = (TextView) convertView.findViewById(R.id.listitems);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.Name.setText(lis.get(position).getStartingHrs()+":"+lis.get(position).getStartingMinutes()+"\n "+lis.get(position).getEndHrs()
				+":"+lis.get(position).getEndMinutes()+"\n "+lis.get(position).getSource()+"\n\n");
		
		return convertView;

	}
	
	static class ViewHolder {
		  TextView Name;
	}

}
